package jvm

/**
 * @Author: DRevelation
 * @Date: 2021/9/17 15:00
 */

fun main() {
    println("Hello Kotlin")
    printMessage("kotlin")
    printMessageWithPrefix("kotlin")
    printMessageWithPrefix("kotlin", "hello")

    println("==================================")
    println(2 times "Kotlin ")

    val dog: Dog = Yorkshire()
    dog.sayHello()
}

fun printMessage(message: String): Unit = println(message)

fun printMessageWithPrefix(message: String, prefix: String = "Info") {
    println("[$prefix] $message")
}

fun sum(x: Int, y: Int): Int {
    return x + y
}

infix fun Int.times(str: String) = str.repeat(this)

//class Person(val name: String) {
//    private val likePeople = mutableListOf<Person>()
//    infix fun likes(other: Person) {
//        likePeople.add(other)
//    }
//}

fun describeString(maybeString: String?): String {
    return if (maybeString != null && maybeString.isNotEmpty()) {
        "String of length ${maybeString.length}"
    } else {
        "Empty or null string"
    }
}

open class Dog {
    open fun sayHello() {
        println("wow wow!")
    }
}

class Yorkshire : Dog() {
    override fun sayHello() {
        println("wif wif!")
    }
}
